﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace BlueLotus7
{
    partial class Validator
    {
        public static bool IsId(string stringToCheck, int minLength, int maxLength)
        {
            if (stringToCheck != null)
            {
                Regex regex = new Regex(@"^[0-9a-zA-Z][0-9a-zA-Z]{" + (minLength - 1).ToString() + "," + (maxLength - 1).ToString() + "}$");
                if (regex.IsMatch(stringToCheck))
                    return true;
            }
            return false;
        }

        public static bool IsExternalId(string stringToCheck, int minLength, int maxLength, string externalCharsets)
        {
            if (externalCharsets == null)
            {
                return IsId(stringToCheck, minLength, maxLength);
            }
            else
            {

                if (stringToCheck != null)
                {
                    Regex regex = new Regex(@"^[0-9a-zA-Z][0-9a-zA-Z" + externalCharsets + "]{" + (minLength - 1).ToString() + "," + (maxLength - 1).ToString() + "}$");
                    if (regex.IsMatch(stringToCheck))
                        return true;
                }
            }
            return false;
        }
    }
}
